package com.clerkq.ProgressBar
{
	import com.library.core.IDisposable;
	import com.library.core.UIObject;
	import com.library.utils.vily.CircleDrawer;
	import com.library.utils.vily.DrawArc;
	import com.library.utils.vily.Vector_2D;
	
	import flash.display.MovieClip;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.text.TextField;
	
	
	// 这个是做为内嵌，在Preload中唯一使用的类
	public class ProgressBarCircle extends ProgressBar
	{
		[Embed(source="EmbedSkin.swf", symbol="ProgressBar_Circle")]		
		private var Skin:Class;
		
		private var _asset:Sprite;
		private var _text:TextField;
		
		public var drawer:DrawArc = null;
		private var c_pos:Vector_2D = null;
		private var circleDrawer:CircleDrawer = null;
		private var box_spr:Sprite = null;
		
		private var r_a_num:Number = 20;
		private var r_b_num:Number = 28;
		private var fillColor:uint = 0x109dff;
		//起始角度
		private var startAng:Number = -90;
		private var maxArcAng:Number = 360;
		private var arcAng:Number = 0;
		
		public function ProgressBarCircle()
		{
			super();
			AddBG();
			AddShape();
			AddText();
		}
		
		private function AddBG():void{
			_asset = new Skin() as Sprite;			
			addChild(_asset);
		}
		private function AddShape():void{
			
			circleDrawer = new CircleDrawer();
			circleDrawer.fillAlpha = 0.8;
			circleDrawer.fillColor = fillColor;
			
			drawer = new DrawArc();
			c_pos = new Vector_2D(0, 0);
			
			box_spr = new Sprite();
			addChild(box_spr);
		}
		private function AddText():void{
			_text = _asset["indicatorTXT"]; 
		}
		
		private function UpdateClock(progress:Number):void{
			/*var radius:Number = 25;
			var degree:Number = (360 / 100) * (progress);
			_pen.graphics.clear();
			_pen.graphics.beginFill(0x8ea0ca, 1.0);
			_pen.graphics.moveTo(0,0);
			_pen.graphics.lineTo(0,radius);
			for(var i:uint = 0; i <= degree; i++){
				var degree2:Number = Math.PI/180*(i-90);
				var x:Number = Math.cos(degree2)*radius;
				var y:Number = Math.sin(degree2)*radius
				_pen.graphics.lineTo(x,y);
			}
			_pen.graphics.endFill();*/
			arcAng = int(maxArcAng * (progress/100));
			circleDrawer.drawCirqueShape(box_spr,c_pos,r_a_num,r_b_num,startAng,arcAng,3,true);
		}
		
		// public //////////////////////////////

        // 0 ~ 100
		override public function SetPercentage(percent:int):void{
			var txt:String = int(percent).toString();
			txt += "%";
			_text.text = txt;
			UpdateClock(percent);
		}
        
        override public function Dispose():void	{}
		
	}
}